package com.lanou3g.ptp.achievement.mapper;

import com.lanou3g.ptp.entity.Diary;
import com.lanou3g.ptp.vo.DiaryDetails;
import com.lanou3g.ptp.vo.DiaryVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

@Mapper
public interface DiaryMapper {

    List<Diary> findAll();

    List<Diary> findAll1();

    List<Diary> findByKeyword(String keyword);

    Diary findDiaryById(Long id);

    int insert(Diary diary);

    void updateDiary(@Param("id") Long id, @Param("diary") Diary diary);

    void deleteDiaryId(Long id);

    void deleteDiaryIds(Long[] ids);

    List<Diary> myFindAll(Long id);

    List<Diary> find(@Param("studentId") Long id, @Param("taskId") Long id1);

    Diary findTodayDiaryByStudentId(@Param("studentId") Long studentId, @Param("taskId") Long taskId,
                                    @Param("startDate") Date startDate, @Param("endDate") Date endDate);

    List<Diary> findDiarySituation(@Param("time1") Date time1, @Param("time2") Date time2,
                                   @Param("taskId") Long taskId);

    List<Diary> findDiariesWithLikesAndCommentsByTaskId(@Param("taskId") Long taskId,
                                                        @Param("limit") Integer limit);

    List<Diary> findDiariesWithLikesAndCommentsByTeachlinkId(@Param("teachlinkId") Long teachlinkId,
                                                             @Param("limit") Integer limit);

    long countByTaskId(Long taskId);

    long countByTeachlinkId(Long teachlinkId);

    List<DiaryDetails.Student> findStuDiaryDetails(Long taskId);

    @Delete("DELETE FROM diary WHERE `id`=#{diaryId} AND student_id=#{studentId}")
    int deleteByDiaryIdAndStudentId(@Param("diaryId") Long diaryId, @Param("studentId") Long studentId);

    List<DiaryVO> findByTaskAndStudent(@Param("taskId") Long taskId, @Param("studentId") Long studentId);

    int excellentDiary(Long diaryId);

    List<Diary> findByTaskIdAndStudentId(@Param("taskId") Long taskId, @Param("studentId") Long studentId);
}
